From: Bastien Nocera Date: Thu, 15 Sep 2022 16:03:22 +0000 (+0200) Subject: bluetooth: Show the Bluetooth switch in more cases X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~435^2^2~49 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=57aa91e2b3f129ff12c6f87146096708e9ac2867;p=gnome-shell.git bluetooth: Show the Bluetooth switch in more cases In older versions of GNOME, when a menu was used for Bluetooth devices, we tried to avoid showing the Bluetooth menu to folks who didn't use Bluetooth. This kept causing problems as the menu would disappear if no devices were setup and the platform "airplane mode" removed the Bluetooth device from the USB bus, making it impossible to detect whether a Bluetooth device existed, compared to a user unplugging a removable Bluetooth device. Closes: #5749 Part-of: --- diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index d4de597ad..f5ed1775b 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -64,7 +64,10 @@ const BtClient = GObject.registerClass({ g_interface_info: rfkillManagerInfo, }); this._proxy.connect('g-properties-changed', (p, properties) => { - if ('BluetoothHardwareAirplaneMode' in properties.unpack()) + const changedProperties = properties.unpack(); + if ('BluetoothHardwareAirplaneMode' in changedProperties) + this.notify('available'); + else if ('BluetoothHasAirplaneMode' in changedProperties) this.notify('available'); }); this._proxy.init_async(GLib.PRIORITY_DEFAULT, null) @@ -79,21 +82,19 @@ const BtClient = GObject.registerClass({ this._connectDeviceNotify(deviceStore.get_item(i)); this._client.connect('device-removed', (c, path) => { - this._syncHadSetupDevices(); this._deviceNotifyConnected.delete(path); this.emit('devices-changed'); }); this._client.connect('device-added', (c, device) => { - this._syncHadSetupDevices(); this._connectDeviceNotify(device); this.emit('devices-changed'); }); } get available() { - // If there were set up devices, assume there is an adapter - // that can be powered on as long as we're not hard blocked - return this._hadSetupDevices + // If we have an rfkill switch, make sure it's not a hardware + // one as we can't get out of it in software + return this._proxy.BluetoothHasAirplaneMode ? !this._proxy.BluetoothHardwareAirplaneMode : this.active; }